import com.bit.demo.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2023-07-18
 * Time: 22:05
 */
public class GetBeanExample {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
        //通过类型获取Bean,但是如果xml中存在多个UserService会出错
        UserService userService =context.getBean(UserService.class);
        userService.sayHi();

    }
}
